package com.ele.web;

import com.ele.pojo.PageResult;
import com.ele.pojo.vo.FoodCategoryVO;
import com.ele.service.FoodCategoryService;
import com.ele.service.impl.FoodCategoryServiceImpl;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findFoodCategory")
public class FindFoodCategoryServlet extends HttpServlet {
    private FoodCategoryService foodCategoryService = new FoodCategoryServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        String shopId = req.getParameter("shopId");
        PageResult<List<FoodCategoryVO>> pageResult = foodCategoryService.findFoodCategory(currentPage, pageSize, shopId);


        String json = new Gson().toJson(pageResult);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
